package com.sky.controller.admin;

import com.sky.constant.RedisKeyConStant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "店铺操作接口")
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    @ApiOperation("修改店铺状态")
    @PutMapping("/{status}")
    public Result changShopStatus(@PathVariable("status") Integer status){
        redisTemplate.opsForValue().set(RedisKeyConStant.SHOP_STATUS_KEY,status);
        return Result.success();
    }

    @ApiOperation("管理端获取店铺状态")
    @GetMapping("/status")
    public Result ShopGetStatus(){
        Object o = redisTemplate.opsForValue().get(RedisKeyConStant.SHOP_STATUS_KEY);
        return Result.success(o);
    }
}
